package cpa.prowon.gui.util;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;

/**
 * This class supports color management
 * @author Chris
 */
public class ColorManager
{
	
	private static ColorManager _instance;
	private Color[] gradient;
	
	/**
	 * @author Chris
	 */
	private ColorManager()
	{
	}

	/**
	 * Return the one and only instance
	 * @author Chris
	 */
	public static ColorManager getInstance()
	{
		if (_instance == null)
		{
			_instance = new ColorManager();
		}
		return _instance;
	}

	/**
	 * Return the system color for the specified color index
	 * @param int The color index
	 * @return The system color for the specified color index
	 * @author Chris
	 */
	public Color getColor(int i)
	{
		return Display.getCurrent().getSystemColor(i);
	}
	
	/**
	 * Return the gradient system color for the title bars of the viewers
	 * @return The system colors that make up the gradient look
	 * @author Chris
	 */
	public Color[] getColorGradient()
	{
		if (gradient == null)
		{
			Color firstColor = getColor(SWT.COLOR_TITLE_BACKGROUND);
			Color middleColor = getColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT);
			Color endColor = getColor(SWT.COLOR_WIDGET_BACKGROUND);
			gradient = new Color[] { firstColor, middleColor, endColor };
		}
		return gradient;
	}
	
	/**
	 * Return the color gradient ratio for the nice looking viewer
	 * title bars
	 * @return The color gradient ratio
	 * @author Chris
	 */
	public int[] getColorGradientRatio() {
		return new int[] {50, 100};
	}
	
}
